package top.lyjwn.todo.weinxin;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import top.lyjwn.todo.weinxin.param.WXAppletParam;
import top.lyjwn.todo.weinxin.param.WXBjnewsParam;

/**
 * 微信配置
 *
 * @author luoyujie
 */
@Configuration
public class WXBjnewsConfig implements EnvironmentAware {

    private Environment environment;

    @Override
    public void setEnvironment(Environment environment) {
        this.environment= environment;
    }

    @Bean
    public WXBjnewsParam getWXBjnewsParam() {
        WXBjnewsParam wxBjnewsParam = new WXBjnewsParam();
        String appid = this.environment.getProperty("lyjwn.weinxin.bjnews.appid");
        wxBjnewsParam.setAppid(appid);
        String appsecret = this.environment.getProperty("lyjwn.weinxin.bjnews.appsecret");
        wxBjnewsParam.setAppsecret(appsecret);
        String domain_name = this.environment.getProperty("lyjwn.weinxin.bjnews.domain_name");
        wxBjnewsParam.setDomain_name(domain_name);
        String auth_domain_name = this.environment.getProperty("lyjwn.weinxin.bjnews.auth_domain_name");
        wxBjnewsParam.setAuth_domain_name(auth_domain_name);
        String token = this.environment.getProperty("lyjwn.weinxin.bjnews.token");
        wxBjnewsParam.setToken(token);
        String isAccess = this.environment.getProperty("lyjwn.weinxin.bjnews.isAccess");
        wxBjnewsParam.setAccess(isAccess==null||"".equals(isAccess));
        return  wxBjnewsParam;
    }


//    /**
//     * 微信公众号appid
//     */
//    public static String APPID;
//    /**
//     * 第三方用户唯一凭证密钥
//     */
//    public static String APPSECRET;
//    /**
//     * 系统域名
//     */
//    public static String DOMAIN_NAME;
//
//    /**
//     * 授权域名
//     */
//    public static String AUTH_DOMAIN_NAME = "";

    /*
    @Value("${top.lyjwn.todo.weinxin.bjnews.appid}")
    public void setAPPID(String APPID) {
        WXBjnewsConfig.APPID = APPID;
    }

    @Value("${top.lyjwn.todo.weinxin.bjnews.appsecret}")
    public void setAPPSECRET(String APPSECRET) {
        WXBjnewsConfig.APPSECRET = APPSECRET;
    }

    @Value("${top.lyjwn.todo.weinxin.bjnews.domain_name}")
    public void setDomainName(String domainName) {
        DOMAIN_NAME = domainName;
    }

    @Value("${top.lyjwn.todo.weinxin.bjnews.auth_domain_name}")
    public void setAuthDomainName(String authDomainName) {
        AUTH_DOMAIN_NAME = authDomainName;
    }


    @Value("${top.lyjwn.todo.weinxin.bjnews.WXBUserController.token}")
    private String token;


    @Value("${top.lyjwn.todo.weinxin.bjnews.WXBUserController.isAccess}")
    private boolean isAccess;
     */
}
